<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // aabccd统计每个字符出现的次数，去掉重复的字符，使结果显示 abcd
        var str = "aabccd";
        var obj = {};
        for (var j = 0; j < str.length; j++) {
            if (obj[str[j]]) {
                obj[str[j]]++
            } else {
                obj[str[j]] = 1
            }
        }
        console.log(obj);
        var res = str.split("").sort();
        for (var i = 0; i <= res.length - 1; i++) {
            if (res[i] === res[i + 1]) {
                res.splice(i, 1)
            }
        }
        var newres = res.join("");
        console.log(newres)
    </script>
</head>

<body>

</body>

</html>